<?php

class Menu_model extends CI_Model{
	
	var $menuitems;
	
	//The mode for the menu, need to get some stuff from the database
	function __construct(){
		parent::__construct();
		
		$this->load->helper('html');
		$this->load->helper('url');
		
		$this->menuitems = array('home' => array('name' => 'Home', 'url' => 'index.php/playback/home/'), 
			'project_info' => array('name' => 'Project Info', 'url' => 'index.php/playback/project_info/'),
			'articles' => 
			array('name' => 'Articles', 'url' => 'index.php/articles/', 
				'submenu' => $this->_getArticlesCategories()),
				'Forum' => array('name' => 'Forum', 'url' => 'index.php/forum/'));
	}
	
	//Returns all the content in the menu
	function getMenuItem($item){
		return $this->menuitems[$item];
	}
	
	//Gets the categories that is defines in the database.
	function _getArticlesCategories(){
		
		$this->load->model('articles_model');
		$submenu = array();
		$artcats = $this->articles_model->getCategories();
		
		foreach($artcats as $row){
			
			$tmp = array('name'=>$row->name, 'url'=>$row->url);
			array_push($submenu, $tmp);
		}
		
		return $submenu;
	}
	
}